using MediatR;
using SumerCoreDevOps.Application.Users.Commands;
using SumerCoreDevOps.Infrastructure.Identity;

namespace SumerCoreDevOps.Application.Users.Handlers;

/// <summary>
/// 重置密码命令处理器
/// </summary>
public class ResetPasswordCommandHandler : IRequestHandler<ResetPasswordCommand, string>
{
    private readonly UserManager _userManager;

    public ResetPasswordCommandHandler(UserManager userManager)
    {
        _userManager = userManager;
    }

    public async Task<string> Handle(ResetPasswordCommand request, CancellationToken cancellationToken)
    {
        return await _userManager.ResetPasswordAsync(request.UserId, request.AdminUser);
    }
}
